Method and System for Extracting Web Query Interfaces

ABSTRACT

A computer program product being embodied on a computer readable medium for extracting semantic information about a plurality of documents being accessible via a computer network, the computer program product including computer-executable instructions for: generating a plurality of tokens from at least one of the documents, each token being indicative of a displayed item and a corresponding position; and, constructing at least one parse tree indicative of a semantic structure of the at least one document from the tokens dependently upon a grammar being indicative of presentation conventions.

RELATED APPLICATIONS

The present application is a continuation of application Ser. No. 10/913,721 filed on Aug. 6, 2004, the contents of which are incorporated by reference herewith in their entirety.

GOVERNMENTAL INTEREST

This invention was made with Government support under contract numbers IIS-0133199 and IIS-0313260 awarded by the national science foundation. The Government has certain rights in the invention.

FIELD OF THE INVENTION

The present invention relates generally to information researching and more particularly to web querying.

BACKGROUND OF THE INVENTION

The World Wide Web (“www” or “Web”) continues to rapidly “deepen” by many searchable databases online, where data are hidden behind query forms. Unlike the surface Web providing link-based navigation, these “deep Web” sources support query-based access. Data are thus hidden behind their query interfaces. With the myriad databases online, at the order of 10⁵, the deep Web has clearly rendered large-scale integration a real necessity and a real challenge.

Guarding data behind them, such query interfaces serve as “entrances” to the deep Web. These interfaces, or HTML query forms, express query conditions for accessing objects from databases behind them. Other documents may also guard or provide access to data in an analogous manner. Each condition, in general, specifies an attribute, one or more supported operators (or modifiers), and a domain of allowed values. A condition is thus a three-tuple [attribute; operators; domain] e.g., C_(author)=[author; {“first name . . . ”, “start . . . ”, “exact name”}; text] in interface Q_(am) (see, FIG. 3( a)). Users can then use the condition to formulate a specific constraint e.g., [author=“tom clancy”] by selecting an operator (e.g., “exact name”) and filling in a value (e.g., “tom clancy”).

For modeling and integrating Web databases, the first step is to “understand” what a query interface says—i.e., what query capabilities a source supports through its interface, in terms of specifiable conditions. For instance, amazon.com (FIG. 3( a)) supports a set of five conditions: (on author, title, . . . , publisher). These query conditions establish the semantic model underlying the Web query interface. According to an aspect of the present invention, one may extract such form semantics.

Automatic capability extraction is critical for large-scale integration. Any mediation task generally relies on such source descriptions that characterize sources. Such descriptions, largely constructed by hands today, have been identified as a major obstacle to scale up integration scenarios. For massive and ever-changing sources on the Web, automatic capability extraction is essential for many tasks: e.g., to model Web databases by their interfaces, to classify or cluster query interfaces, to match query interfaces or to build unified query interfaces.

Such form understanding essentially requires both grouping elements hierarchically and tagging their semantic roles: first, grouping associates semantically related HTML elements into one construct. For instance, C_(author) in Q_(am) is a group of 8 elements: a text “author”, a textbox, three radio buttons and their associated texts. Such grouping is hierarchical with nested subgroups (e.g., each radio button is first associated with the text to its right, before further grouping). Second tagging assigns the semantic roles to each element (e.g., in C_(author), “author” has the role of an attribute, and the textbox an input domain.)

Such extraction is challenging, since query forms are often created autonomously. This task seems to be rather “heuristic” in nature, with no clear criteria but only a few fuzzy heuristics as well as exceptions. First, grouping is hard, because a condition is generally n-ary, with various numbers of elements nested in different ways. ([heuristics]: Pair closest elements by spatial proximity. [exception]: Grouping is often not pairwise.) Second, tagging is also hard, as there is no semantic labeling in HTML forms. ([heuristics]: A text element closest to a textbox field is its attribute. [exception]: Such an element can instead be an operator of this or next field.) Finally, with various form designs, their extraction can be inherently confusing—The infamous Florida “butterfly” ballots in US Election 2000 indicate that ill-designed “forms” can be difficult, even for human voters, to simply associate candidates with their punch holes. This incident in fact generated discussions on Web-form designs.

SUMMARY OF THE INVENTION

A computer program product being embodied on a computer readable medium for extracting semantic information about a plurality of documents being accessible via a computer network, the computer program product including computer-executable instructions for: generating a plurality of tokens from at least one of the documents, each token being indicative of a displayed item and a corresponding position; and, constructing at least one parse tree indicative of a semantic structure of the at least one document from the tokens dependently upon a grammar being indicative of presentation conventions.

BRIEF DESCRIPTION OF THE FIGURES

Understanding of the present invention will be facilitated by consideration of the following detailed description of the preferred embodiments of the present invention taken in conjunction with the accompanying drawings, in which like numerals refer to like parts and in which:

FIG. 1 illustrates a hidden-syntax hypothesis according to an aspect of the present invention;

FIG. 2 illustrates a form extractor for web query interfaces according to an aspect of the present invention

FIG. 3 illustrates query interface examples according to an aspect of the present invention;

FIG. 4 illustrates data for a query vocabulary using condition patterns as building blocks for query interfaces hypothesis according to an aspect of the present invention;

FIG. 5 illustrates tokens T in a fragment of interface Q_(am) according to an aspect of the present invention;

FIG. 6 illustrates productions of a 2P grammar according to an aspect of the present invention;

FIG. 7 illustrates two interpretations for text s₁ according to an aspect of the present invention;

FIG. 8 illustrates two interpretations for a radio button list according to an aspect of the present invention;

FIG. 9 illustrates two parse trees for interface Q1 according to an aspect of the present invention;

FIG. 10 illustrates fix-point processing according to an aspect of the present invention;

FIG. 11 illustrates a parser for a 2P grammar according to an aspect of the present invention;

FIG. 12 illustrates a 2P schedule graph for a grammar G according to an aspect of the present invention;

FIG. 13 illustrates a transformation of an r-edge according to an aspect of the present invention;

FIG. 14 illustrates partial trees for an interface Q_(aa) fragment according to an aspect of the present invention;

FIG. 15 illustrates data indicative of precision and recall for a system according to an aspect of the present invention;

FIG. 16 illustrates exemplary patterns according to an aspect of the present invention; and,

FIGS. 17A-17C illustrate an exemplary operation of a parser according to an aspect of the present invention.

DETAILED DESCRIPTION OF THE INVENTION

It is to be understood that the figures and descriptions of the present invention have been simplified to illustrate elements that are relevant for a clear understanding of the present invention, while eliminating, for purposes of clarity, many other elements found in typical querying methods and systems. However, because such elements are well known in the art, and because they do not facilitate a better understanding of the present invention, a discussion of such elements is not provided herein. The disclosure herein is directed to all such variations and modifications known to those skilled in the art.

According to an aspect of the present invention, an approach that builds on the observation that, across myriad sources, query forms seem to reveal some “concerted structure,” by sharing common building blocks may be used. Toward this insight, one may hypothesize the existence of a hidden syntax that guides the creation of query interfaces, albeit from different sources. This hypothesis effectively transforms query interfaces into a visual language with a non-prescribed grammar and, thus, their semantic understanding a parsing problem. Such a paradigm enables principled solutions for both declaratively representing common patterns, by a derived grammar, and systematically interpreting query forms, by a global parsing mechanism. To realize this paradigm, one may address the challenges of a hypothetical syntax, that it is to be derived, and that it is secondary to the input. As the heart of a form extractor, one may use a 2P grammar and a best-effort parser, which together realize a parsing mechanism for a hypothetical syntax. According to an aspect of the present invention, it is believed that one may achieve above an 85% accuracy for extracting query conditions across random sources.

As query interfaces are created autonomously, automatic extraction of form semantics is clearly challenging. There seems to be some common “patterns” emerging from heterogeneous query forms. This impression suggests that Web forms are not entirely chaotic (which, if so, would render automatic extraction unlikely). Considering these patterns as the building blocks, or vocabulary, for constructing query forms, one may ascertain this vocabulary. Using search engines (e.g., google.com) and Web directories (e.g., invisibleweb.com), 150 sources were collected, which serves as a Basic dataset, with 50 in each of Books, Automobiles, and Airfares domains. These sources include familiar ones, e.g., amazon.com and aa.com as shown in FIG. 3. These domains were chosen as they are schematically dissimilar and semantically unrelated, and thus constitute a diverse “sample” of Web sources.

The survey established that query interfaces reveal some concerted structure: such that about 25 condition patterns may be suitable for use, which is surprisingly small as a vocabulary for online queries. Exemplary patterns are illustrated in FIG. 16.

FIG. 4( a) summarizes the occurrences of 21 “more-than-once” patterns. The figure marks (x, y) with a “+” if pattern y occurs in source x. As more sources are seen (along the x-axis), the growth (along y) of the vocabulary slows down and thus the curve flattens rapidly. Further, one may observe that the convergence generally spans across different domains (e.g., Automobiles and Airfares are mostly reusing the patterns from Books), which indicates that most condition patterns are quite generic and not domain specific.

One may also observe that the distribution is extremely non-uniform: FIG. 4( b) ranks these 21 patterns according to their frequencies, for each domain and overall. A characteristic Zipf-distribution may be observed, which means that a small set of top-ranked patterns is very frequently used.

Accordingly, according to an aspect of the present invention, one may imply that the small and converging vocabulary, which occurs across autonomous sources and even across diverse domains, indicates that there are conventions (or “design patterns”) emerging among Web query forms. While each form is different, together they share a relatively small set of vocabulary. Further, the non-uniform distribution of patterns suggests that, to leverage such conventions, even if one can not exhaustively cover all patterns, a few frequent ones will likely pay off significantly.

The concerted-structure illustrates that form understanding can be promising, by leveraging, presentation conventions. Intuitively, given a query form, one may thus build an understanding of it by decomposing it into some known patterns, each of which has been seen before. Thus, an interpretation of an interface unseen before may be assembled of known patterns. This “divide-and-conquer” approach allows a small vocabulary of such patterns to be shared across diverse query forms.

To use these layout patterns, it may be tempting to “simply” code up each pattern as a rule-of-thumb, e.g., the pairwise-proximity grouping heuristic. However, to specify these patterns, such procedural description will involve convoluted code, lacking both generality and extensibility. Further, to recognize these patterns, it is far from clear, beyond individual heuristics, how they together form a coherent interpretation of the query form.

Accordingly, a hidden syntax behind Web query interfaces, across different sources, may be leveraged. This rationalizes the observed concerted structure. As FIG. 1 illustrates, a query form creation as guided by such a hypothetical syntax, which connects semantics (i.e., query conditions) to presentations (i.e., query forms) may be used. Such a hidden syntax represents the presentation conventions across Web forms. Unlike traditional string languages (e.g., programming languages), this syntax uses visual effects to express the embedded semantics (e.g., pattern 1 in FIG. 3( c) arranges the attribute to be left-adjacent and bottom-aligned to the input field).

Thus, a new paradigm is brought forward: viewing query interfaces as a formal language, and in particular, a visual language, whose composition conforms to a hidden, i.e., non-prescribed, grammar. Their semantic understanding, as the inverse, is thus a parsing problem. This “language” paradigm further enables a principled algorithmic framework for form understanding—a task that appears inherently heuristic at first. By the hidden-syntax hypothesis, one may resort to a formal framework for languages. That is, according to an aspect of the present invention, the dual notions of a grammar and a parser together provide a systematic framework for both specifying and recognizing common patterns.

For pattern specification, the grammar provides a declarative mechanism. Such patterns (e.g., FIG. 3( c)) may simply be declared by productions (i.e., grammar rules) that encode associated visual characteristics. The specification of patterns is thus declarative, fully separated from and independent of how they are recognized individually and assembled globally by the parser. By incorporating arbitrary spatial relations (instead of, say, only proximity), one can describe complex visual patterns. By building productions upon productions, one can describe patterns of different “orders.” One may also simply augment the grammar to add new patterns, leaving the parsing untouched.

For pattern recognition, the parser provides a global mechanism for systematically constructing a parse tree as a coherent interpretation of the entire query interface. Such a parse naturally structures elements in nested sub-trees, thus satisfying the grouping requirement. Further, it assigns grammatical alphabet symbols (terminals and non-terminals) to each construct, thus satisfying the tagging requirement. Finally, it should be noted that such parsing leverages not only individual patterns but also their coherent assembly into an entire query form, thus resolving local conflicts by a global context. Parsing thus systematically realizes the intuitive “divide-and-conquer” approach.

As the hidden syntax enables a new paradigm, it may present new challenges. For example, as this hypothetical nature implies, the grammar is non-prescribed. That is, instead of being prescribed before query forms are created, it is simply derived from whatever conventions naturally emerge. Further, the grammar may be secondary to any language instance. That is, instead of dictating form creation, it may rely on the language's natural convergence to derive any convention. Thus, first, for capturing the hypothetical syntax, the grammar may represent “conventions” used for Web form presentation. Further, while one may ideally want to capture all patterns across many forms, unlike in a carefully-orchestrated grammar, these patterns may not be mutually “compatible.” One may thus rethink the right mechanism for such a derived grammar, to capture necessary conventions for enabling parsing. Second, a derived grammar may be inherently incomplete (with uncaptured patterns) and ambiguous (with conflicting patterns). Thus, such a grammar may only be secondary to input. Further, unlike traditional parsing, a parser according to the present invention may not reject input query forms, even if not fully parsed, as “illegal.” That is, the parser may no longer “police” a language for checking and enforcing grammar rules. It may instead be a “soft” parser that accepts any input. The right semantics for such a soft parser, and further, its realization should thus be accordingly derived.

According to an aspect of the present invention, one may build upon the traditional language framework. First, as a derived grammar for capturing the hypothetical syntax, the 2P grammar encodes not only “patterns” but also their “precedence.” Second, as a soft-parser directed by a hypothetical syntax, when a single perfect parse does not exist, the best-effort parser resolves ambiguities as much as possible and constructs parse trees as large as possible.

To capture the hidden syntax, a grammar may be used to encode two complementary types of presentation conventions. On one hand, ideally all conventional patterns are captured. On the other hand, however, by capturing many patterns, some will conflict, and thus a conventional precedence (or “priorities”) may also be captured.

The grammar mechanism may encode both conventions by productions and preferences respectively (and thus the 2P name). That is, it may capture knowledge for both pattern construction (by productions) and ambiguity resolution (by preferences). According to an aspect of the present invention a 2P grammar may take the form of a 5-tuple (Σ, N, s, P_(d), P_(f)), where Σ is a set of terminal symbols, N is a set of nonterminal symbols, sεN is a start symbol, P_(d) is a set of production rules, and P_(f) is a set of preference rules. This 2P grammar mechanism may be used to express the hypothetical syntax. Such a grammar may be derived from analyzing and abstracting common patterns.

In turn, a best-effort parser works with the hypothetical syntax. As explained earlier, a derived grammar will be inherently ambiguous and incomplete. A “soft parser” that assembles parse trees that may be multiple (because of ambiguities) and partial (because of incompleteness), instead of insisting on a single perfect parse may be used. First, it may prune ambiguities, as much (and as early) as possible, by employing preferences (as in the 2P grammar). Second, it may recognize the structure (by applying productions) of the input form, as much as possible, by maximizing partial results.

In general, a form extractor may be built in a language-parsing framework. Given an input HTML query form, the form extractor outputs its semantic model (or the query capabilities) of the form. At the heart, the best effort parser may work with a derived 2P-grammar to construct multiple and partial parse trees. As preprocessing, a tokenizer may prepare the input to the core parser, by converting the input HTML form into a set of basic tokens, which are the atomic units in the visual grammatical composition. As post-processing, the merger integrates the output of the parser to generate the final semantic model.

More particularly, at the front-end, the tokenizer converts an HTML query form (in a Web page) into a set of tokens, each representing an atomic visual element on the form. These tokens are instances of the terminals Σ as the 2P grammar defines. Each token thus has a terminal type and some attributes recording properties necessary for parsing. For instance, given the HTML fragment (as part of interface Q_(aa)), as shown in FIG. 5, the tokenizer extracts a set T of 16 tokens. In particular, token s₀ is a text terminal, with attributes sval=“Author” (its string value) and pos=(10, 40, 10, 20) (its bounding-box coordinates). Although different terminals have different attributes, this pos attribute is universal, as the grammar captures two dimensional layout. Such a tokenizer thus essentially builds on a layout engine for rendering HTML into its visual presentation. In particular, the tokenizer may use the HTML Document Object Model (DOM) API (available in browsers, e.g., Internet Explorer), which provides access to HTML tags and their positions.

At the back-end, the merger combines the multiple partial parse trees that the parser outputs, to compile the semantic model and report potential errors (if any). Since the parser is rather generic, this step applies application (i.e., query form) specific processing. First, as the goal is to identify all the query conditions, the merger combines multiple parse trees by taking the union of their extracted conditions. As each parse covers different parts of the form, this union enhances the coverage of the final model constructed. For example, given a fragment of interface Q_(aa), as FIG. 14 shows, the parser will generate three partial parses (trees 2, 3, 4 in the figure). Their union covers the entire interface and generates all the conditions.

The merger also reports errors, which are useful for further error handling by a “client” of the form extractor. Two types of errors may be reported. First, a conflict occurs if the same token is used by different conditions. In FIG. 14, tree 2 associates the number selection list with number of passengers, while tree 3 with adults, and thus they conflict by competing for the number selection. (In this case, tree 3 is the correct association.) Second, a missing element is a token not covered by any parse tree. The merger reports both types of errors for further client-side handling.

As the key component in the parsing framework, the 2P grammar captures presentation conventions of Web interfaces. Specifically, the 2P grammar declaratively and comprehensively specifies both condition patterns and their precedence, as a principled way to express a derived syntax and to resolve potential ambiguities. In particular, productions formally specify common condition patterns and preferences their relative precedence.

Since the condition patterns establish a small set of building blocks for Web interfaces, appropriate presentational characteristics to capture those condition patterns as productions may be used. In particular, in query interfaces, visual effects such as topology (e.g., alignment, adjacency) and proximity (e.g., closeness) are frequently used for expressing semantically related components and thus are the candidates to be captured by productions. Some features, such as proximity, work well for simple interfaces. However, it may be difficult to extend this to complex interfaces, which difficulty can often result in incorrect interpretations. On the other hand, topology features such as alignment and adjacency (e.g., left, above) often accurately indicate the semantic relationships among the components in query interfaces. According to an aspect of the present invention, topological information may be analyzed in the productions, to capture condition patterns.

Two-dimensional grammars have been proposed in visual languages to realize such specifications of visual patterns, e.g., relational grammar, constraint multiset grammar, positional grammar. The 2P grammar (without considering the preferences) may be considered a special instance of attributed multiset grammar, where a set of spatial relations capturing topological information (e.g., left, right) are used in productions.

The main extension of two dimensional grammars from string grammars (e.g., for programming languages) is to support general constraints. In two dimensional grammars, productions need to capture spatial relations, which essentially are constraints to be verified on the constructs. For example, consider production P5 in FIG. 6. To capture the pattern TextOp (used by author in interface Q_(aa)), Attr may be specified as being left to Val and Op below to Val. (Note that, in the 2P Grammar, adjacency may be implied in all spatial relations and thus omitted in the constraint names). In contrast, productions in string grammars only use one constraint, the sequentiality among components.

As a consequence, such extension leads to adaptations in other aspects of the productions. Specifically, to support the general constraints, each symbol has a set of attributes (e.g., pos of Attr, Op and Val), which stores the information used in constraints evaluation (e.g., left, below). Further, each production has a constructor, which defines how to instantiate an instance of the head symbol from the components. For example, after applying the production P5 to generate a new TextOp instance I, the constructor computes I's position from its components. Formally, we define the production as: A production P in a 2P grammar G=(Σ, N, s, Pd, Pf) is a four-tuple (H, M, C, F): Head HεN is a nonterminal symbol; Components M≡Σ∪N is a multiset of symbols; Constraint C is a Boolean expression defined on M; and Constructor F is a function defined on M, returning an instance of H.

Referring now to FIG. 6, there is shown an Example 1, wherein grammar G that specifies 11 productions labeled from P1 to P11. Each production defines a non-terminal (e.g., TextOp and EnumRB) as its head. The start symbol is QI and the terminal symbols are text, textbox and radiobutton. Note that, to simplify the illustration, the production constructors have been omitted in FIG. 6.

Productions P3 to P11 capture three patterns (patterns 1 and 2 in FIG. 3( c) in addition to TextOp introduced above). Productions P1 and P2 capture the form pattern by which condition patterns are arranged into query interfaces. In particular, we consider a query interface QI as composing of vertically aligned “rows” HQI, where each HQI further composes of horizontally aligned condition patterns CP.

As will be understood by those possessing an ordinary skill in the pertinent arts, productions provide a general and extensible mechanism for describing patterns. First, it can express patterns of different “orders”: such that complex patterns are built upon simpler ones. For example, pattern TextOp is constructed from simpler patterns Attr, Op and Val, and in turn serves as the basis of higher order patterns such as QI. Second, being extensible, it may incorporate new patterns and new constraints, while leaving the parsing algorithm untouched. As is discussed below, by changing the grammar, exactly the same parsing framework can be used for other applications.

For derived grammars, precedence may be used to resolve conflicts among patterns, and thus form an integral component of the 2P grammar. While the grammar may capture as many common (but non-prescribed) patterns as possible, those patterns may not be “compatible,” which results in significant ambiguities. To resolve those ambiguities, a preference framework which captures the conventional precedence among condition patterns may be used.

Again, an ambiguity results when there exist multiple interpretations for the same token, and therefore these interpretations conflict on such a token. As Example 2, to capture the condition pattern TextVal used by from condition in Q_(aa) and pattern RBU used in Q_(am), one may define productions P4 and P9 respectively. However, such generality brings ambiguities, allowing a token to be interpreted differently by different patterns. Consider the text token s₁ (i.e., “first name/initial and last name”) in FIG. 5, pattern TextVal(P4) and RBU(P9) have different interpretations on s₁, as FIG. 7 shows. In particular, TextVal interprets it as an Attr instance AI in a TextVal instance I1 (FIG. 7( a)). In contrast, RBU interprets it as the text of a RBU instance I2 (FIG. 7( b)). Since conflicting on s₁, I1 and I2 cannot appear in the same parse tree.

Thus, the existence of ambiguities may cause parsing inefficient and inaccurate. It is inefficient because of local ambiguities. That is, the parser may generate “temporary instances” that will not appear in any complete parse tree. An ambiguity first name/initials and last name Instance between two instances is local if at least one of them is a temporary instance. Again considering the above example 2, I1 is a temporary instance, since we cannot further derive a complete parse tree from I1. In contrast, we can derive complete parse trees from I2 (as FIG. 9 shows two). Hence, such an ambiguity is local because it can eventually be resolved at the end of parsing. According to an aspect of the present invention, the parser may generally follow a bottom-up exhaustive approach, which explores all possible interpretations. Therefore, the existence of local ambiguities may make parsing very inefficient due to the generation of many “temporary instances.”

In contrast, global ambiguities make the parsing results inaccurate. That is, the parsing may generate more parse trees than the semantically correct one. An ambiguity between two instances is global if they lead into different parse trees, and thus cannot be resolved even at the end of parsing.

As Example 3, to capture radio button lists of arbitrary length, production P8 is defined in a recursive way. As a result, a radio button list of length three can have four interpretations, depending on how they are grouped. FIG. 8 shows such two—(a) as a single list or (b) as three individual lists with each of length one. The ambiguity between these two interpretations is global, because they eventually lead to two different parse trees, as FIG. 9 shows. The first one takes the entire list as an operator of author, while the second takes each list (of length 1) as a condition pattern EnumRB.

The effect of the inherent ambiguities may be significant. For instance, the simple query interface in FIG. 5 has one correct parse tree containing 42 instances (26 non-terminals and 16 terminals). However, applying a basic parsing approach that exhausts all possible interpretations by “brute-force,” 25 parse trees and 773 instances (645 temporary instances and 128 non temporary ones) may be deduced. Conflicting instances may further participate in generating other instances, which in turn conflict, thus causing such a significant misinterpretation. Such exponential aggregation makes ambiguity a significant problem in parsing.

To resolve the significant ambiguities among condition patterns, one may prioritize patterns of a derived grammar. The derived nature of our hidden syntax implies that such precedence comes from “hidden priority conventions” across patterns. In predefined grammars, the creation of a grammar is prior to that of the corresponding language, therefore how to resolve ambiguity is determined apriori. However, in derived grammars, the precedence itself is part of conventions to be derived from the language, and thus cannot be arbitrarily decided. According to an aspect of the present invention, one may use the preference to encode conventional precedence across patterns.

By way of Example 4, there are two conflicting instances, A1 and I2 in the above Example 2. One may observe that text and its preceding radio button are usually tightly bounded together, therefore when conflicting, I2 is more likely to have a higher priority than A1. Such convention of the precedence between patterns may be used to resolve ambiguities. In particular, a precedence convention may be encoded as a “preference” RI: when an RBU instance and an Attr instance conflict on a text token, we arbitrate unconditionally the former as the winner.

In general, a convention may also carry a criterion for picking the winner. For example, for the ambiguity described above, one may observe that a row of radio buttons is usually used as a single longer list rather than separate shorter ones. Therefore, we define a preference R2: when two RBList instances conflict, and if one subsumes the other, pick the longer one as the winner.

Specifically, each preference resolves a particular ambiguity between two types of conflicting instances by giving priority to one over the other. As the above example motivates, such a preference needs to specify the situation and the resolution. The situation indicates the type of conflicting instances (e.g., RBList in preference R2) and the conflicting condition (e.g., subsume). The resolution describes the criteria that the winner instance should satisfy (e.g., longer).

Formally, the preference may be defined as: a Preference R in a 2P grammar G=(Σ, N, s, Pd, Pf) is a three-tuple<I, U, W>: Conflicting instances I=<v1: A, v2: B>, where A,B εN∪Σ, identifies the types of instances v1 and v2 respectively. Conflicting condition U is a Boolean expression on v1, v2 that specifies a conflicting situation to be handled. Winning criteria W is a Boolean expression on v1, v2 that specifies the criteria to pick v1 as the winner.

With 2P grammar capturing the conventions of condition patterns and their preferences, a best-effort parsing algorithm that on one hand makes use of preferences to prune the wrong interpretations in a timely fashion, and on the other hand handles partial results to achieve maximum interpretations for the input may be employed.

With potential ambiguities and incompleteness, the best effort parser operates on a basic framework, the fix-point evaluation as described in R. Helm, K. Marriott, and M. Odersky, Building visual language parsers, In Proceedings on Human Factors in Computing Systems (CHI), pages 105-112, 1991, that progressively and concurrently develops multiple parse trees. The essential idea is to continuously generate new instances by applying productions until reaching a fix-point when no new instance can be generated. For example, as FIG. 10 conceptually shows, the parser starts from a set of tokens T (FIG. 5), iteratively constructs new instances and finally outputs parse trees. In particular, by applying the production P9, one may generate an RBU instance from the text token s₁ and radiobutton r₁. Further, with the production P8, the RBUs in a row together generate an RBList instance. Continuing this process, one may eventually reach the fix-point. A complete parse tree corresponds to a unique instance of the start symbol QI that covers all tokens, as FIG. 10 conceptually shows one. However, due to the potential ambiguities and incompleteness, the parser may not derive any complete parse tree and only end up with multiple partial parse trees.

Upon this framework, we realize the “best-effort” philosophy using: (1) just-in-time pruning to prune the parse trees with wrong interpretations as much and as early as possible; and, (2) partial tree maximization to favor the parse trees that interpret an input as much as possible. FIG. 11 shows an embodiment of a best-effort parsing algorithm 2PParser. Corresponding to the above two components, the algorithm has two phases: first, parse construction with just-in-time pruning, and second, partial tree maximization at the end of parsing. To achieve just-in-time pruning, we schedule the symbols (by procedure BidSchdGraph, explained below) in a proper order so that false instances are pruned timely before further causing more ambiguities. According to the scheduled order, we instantiate the symbols one by one with a fixed point process (by instantiate). Preferences are enforced at the end of each iteration (by enforce) to detect and remove the false instances in this round. When an instance is invalidated, we need to erase its negative effect: false instances may participate in further instantiations and in turn generate more false parents. Procedure rollback is used to remove all those false ancestors to avoid further ambiguity aggregation. Finally, after parse construction phase, PRHandler chooses the maximum parse trees generated in the parse construction phase and outputs them.

For example, and referring now to FIGS. 17A-17C collectively, there is shown an exemplary flow diagram 100 for a parser according to an aspect of the present invention. The parser first builds a dependency graph for scheduling symbols 110. The parser then finds a topological order for the symbols 120. The parser then instantiates the symbols, one-by-one, with a fix-point process 130. Preferences may then be enforced to detect invalidated instances 140. If necessary, a rollback may be performed to remove the effects of invalidated instances 150. The maximum parse tree may then be selected as the result 160, and returned 170. Process BldSchdGraph may proceed along the lines of FIG. 17B. For example, the value of V may be set according to V=Σ+N at step 200. The d-edges of productions may then be added into E 210. The acrylic r-edges of preferences may then be added 220. The acrylic indirect r-edges of preferences may then be added 230. Finally (V, E) may be returned 240. Turning now to FIG. 17C, process instantiate may proceed along the lines shown there in. For example, an initial result may be instantiated 310. All of the productions, with a proper head of the list may then be used to generate instances 320. It may then be determined if the instantiation has changed 330. If so, step 320 may be repeated. If not, the result may be returned 340.

The complexity of the membership problem (i.e., given grammar G, a sentence S, to determine whether SεL(G)) for visual languages is NP-complete. The algorithm may thus run in exponential time with respect to the number of tokens. However, in practice, the use of preferences gives reasonably good performance. Given a query interface of size about 25 (number of tokens), parsing takes about 1 second. Parsing 120 query interfaces with average size 22 takes less than 100 seconds. (The time measured here only includes the parsing time without tokenization and merger.)

To prune false instances as much and as early as possible, a good timing may be used for enforcing the preferences. Such timing would guarantee that any false instance is removed before participating in further instantiations, therefore no rollback is necessary. However, applying preferences whenever a new instance is generated in the basic fix-point algorithm cannot achieve so.

For example (Example 5), with the preference R1 (defined in Example 4) which resolves the local ambiguity in Example 2, the Aftr instance A1 should be removed by the RBU instance I2. But, what if A1 is generated at the very beginning of parsing, while I2 is generated at the end? A1 will still instantiate instance I1 (and possibly others), and only be removed at the end of parsing (when I2 is generated). This “late pruning” makes the preference RI ineffective in controlling ambiguity aggregation.

To address the problem, one may generate the winner instance (e.g., I2) before the loser (e.g., A1) so that the loser can be detected and pruned whenever it is generated. Essentially, one may schedule the instance generation in some desired order consistent with the preferences. As preferences are defined on symbols, to guarantee the order on particular instances, one may enforce such an order on symbols so that the winner symbol produces all its instances before the loser does. Therefore, such symbol-by-symbol instantiation and winner-then-loser order can guarantee that instances are produced in a desired order to ensure just-in-time pruning.

To realize the symbol-by-symbol instantiation, the symbols may be processed in a “children-parent” direction defined by the productions. For example, consider symbol TextOp, as the production P5 defines, the symbols that contribute to the instantiation of TextOp are Attr, Op and Val. Before one processes TextOp, those children symbols may be processed first. Further, to realize the winner-then-loser order, the winner symbol (e.g., RBU in Example 5) may be scheduled before the loser (e.g., Attr).

To schedule the symbols by the above two orders, one may build a 2P schedule graph. The graph consists of the symbols as nodes and two types of edges—d-edges to capture the “children-parent” order defined by the productions and r-edges to capture the winner-then-loser order defined by the preferences.

For example, (Example 6), FIG. 12( c) shows the 2P schedule graph Y for the Grammar G (defined in Example 1), by merging d-edges (FIG. 12( a)) and r-edges (FIG. 12( b)). Y has a d-edge A→B if the grammar has a production with head symbol A and component symbols containing B (i.e., A is a parent of B). Y has an r-edge C→D if the grammar has a preference D over C (i.e., D is the winner and C is the loser). One may omit the self-cycles because they do not affect the scheduling. (More precisely, one may also omit the terminals, as they do not affect the schedule-ability in this example.) By merging these two types of edges, you get the 2P schedule graph Y, with solid edges denoting d-edges and dashed r-edges.

By enforcing a topological order on symbol instantiations, this 2P schedule graph captures the two requirements needed for just-in-time pruning. If the graph is acyclic, any topological order achieves such a goal. For example, as our schedule graph Y (Example 6) is acyclic, we schedule RBU before Attr. Thus, instance I2 is generated before A1, which then is pruned promptly when generated. More precisely, as preferences are enforced at the end of each symbol instantiation to avoid repeated calls for every instance, ambiguities may aggregate during the instantiation of the symbol, which is minimal.

While just-in-time pruning addresses the inherent ambiguities of the grammar, partial parse trees still need to be handled. The parsing algorithm generates partial parse trees when the grammar is incomplete to interpret the entire query interface.

Specifically, partial parse trees are the derivation trees that cover a subset of tokens and can not be expanded further. For instance, when a query interface contains new condition patterns not covered by the 2P grammar, the parse construction will stop at those partial trees, since not being able to further assemble more tokens. For example, consider the query interface in FIG. 14, which is a variation from the interface Q_(aa). Grammar G does not completely capture the form patterns of that interface. The lower part is arranged “column by column” instead of “row by row.” Therefore, the parse construction generates only partial parses, as FIG. 14 shows four of them.

To maximize the understanding of query interfaces, the parser may favor the maximum partial trees that interpret as many tokens as possible. In particular, a maximum subsumption may be used to choose parse trees that assemble a maximum set of tokens not subsumed by any other parse. For example, Tree 1 in FIG. 14 is not maximum because the tokens covered by Tree 1 is subsumed by those of Tree 2. The other three, although overlapping, do not subsume each other. A complete parse tree is a special case of maximum partial tree. In addition to maximizing the interpretations, such maximum parse trees also potentially achieve better interpretations, since they are looking at larger context compared with the non-maximum ones. 

1-21. (canceled)
 22. A computer readable storage medium encoded with a computer program to be executed by a computer for extracting semantic information about a plurality of documents autonomously created by different sources and being accessible via a computer network, said computer readable storage medium comprising: a tokenizer for causing the computer to generate a set of tokens indicative of DOM nodes associated with visual information in a displayed document image from one of the plurality of autonomously created documents; a grammar mechanism for causing the computer to derive a non-prescribed visual grammar from the set of tokens to represent a hidden syntax convention of a visual presentation; and a best-effort parser for causing the computer to apply the derived visual grammar to construct multiple parse trees that represent semantic structure of the document and interpret as many of the set of tokens as the derived visual grammar can.
 23. The computer readable storage medium of claim 22, wherein said tokenizer for causing the computer to generate said set of tokens comprises computer executable instructions for: receiving a document in a mark-up language; rendering said document by a layout engine into a document image; extracting tokens indicative of DOM nodes with visual properties in the rendered document image; and storing said tokens in a memory with visual properties.
 24. The computer readable storage medium of claim 23, wherein said visual properties include, for each token, the coordinates of the token in the displayed document image, the value of the token, the DOM path of the token in the DOM tree, the type of the token, and the name of the token.
 25. The computer readable storage medium of claim 22, wherein said non-prescribed visual grammar is derived from a plurality of autonomously created or heterogeneous Web documents to represent the hidden syntax convention of the visual presentation common among the plurality of autonomously created or heterogeneous Web documents.
 26. The computer readable storage medium of claim 25 wherein said hidden syntax convention of visual presentation is derived by performing the following steps: observing the visual relationship of tokens on how they form semantic units, and deriving visual patterns to represent the semantic unit; and observing precedence between different conflicting patterns and deriving pattern preference to represent their precedence.
 27. The computer readable storage medium of claim 22 wherein said best-effort parser causes the computer to perform a procedure comprising of the steps of: building a schedule graph for determining an order of applying production rules; building multiple parse trees simultaneously by grouping tokens using a set of production rules that represent visual patterns in determined orders; pruning useless parse trees by checking a set of preference rules and that represent pattern precedence; and outputting multiple potential useful parse trees that maximally cover the tokens in the document.
 28. The computer readable storage medium of claim 27 wherein the step of building a schedule graph comprises: adding dependency edges from head symbol to each component symbol for each production rule; adding restriction edges between two symbols for each preference rule; transforming restriction edges when graph is acyclic; and removing restriction edges if graph is still acyclic after said transformation.
 29. The computer readable storage medium of claim 27 wherein the step of building multiple parse trees compromises the steps of: getting productions in the order determined by the schedule graph; and applying each production (H, M, C, F), in the identified order, to generate new instances of the head H, from the instances of the components M, by using the construction function F, if the components M satisfy constraint C.
 30. The computer readable storage medium of claim 27, wherein the step of pruning useless parse trees compromises the steps of: for each newly generated instance, checking the conflicting condition of all preference rules to find all conflicts with existing instances; and applying the winning criteria for conflict resolution to remove false instances.
 31. A method for extracting semantic information about a plurality of electronic documents autonomously created by different sources and being accessible via a computer network, comprising: accessing an electronic document via the computer network; generating a set of tokens by a computer, the tokens indicative of DOM nodes associated with visual information in a displayed document image of the electronic document; deriving a non-prescribed visual grammar from the set of tokens by the computer, to represent a hidden syntax convention of visual presentation in the displayed document image; and applying said derived visual grammar by the computer to construct multiple parse trees that represent semantic structure of the electronic document and interpret as many of the set of tokens as said derived visual grammar can.
 32. The method of claim 31, wherein generating said set of tokens comprises: receiving data representing a document in a mark-up language; rendering said document by a layout engine into a document image; extracting tokens indicative of DOM nodes with visual properties in the rendered document image; and storing said tokens in a memory with visual properties.
 33. The method of claim 32, wherein said visual properties include for each token, the coordinates of the token in the displayed document image, the value of the token, the DOM path of the token in the DOM tree, the type of the token, and the name of the token.
 34. The method of claim 31, wherein said non-prescribed visual grammar is derived from autonomous or heterogeneous Web documents to represent the hidden syntax convention of the visual presentation.
 35. The method of claim 34 wherein said hidden syntax convention of visual presentation is derived by performing the following steps: observing the visual relationship of tokens on how they form semantic units, and deriving visual patterns to represent the semantic unit; and observing precedence between different conflicting patterns and derive pattern preference to represent their precedence.
 36. The method of claim 31 wherein said step of applying said derived visual grammar to construct multiple parse trees that represent semantic structure of the document and interpret as many tokens as said derived visual grammar can comprises the additional steps of: building a schedule graph for determining the order of applying production rules; building multiple parse trees simultaneously by grouping tokens using production rules in determined orders; pruning useless parse trees by checking preference rules; and outputting multiple potential useful parse trees that maximally cover the tokens in the document.
 37. The method of claim 36 wherein the step of building a schedule graph comprises: adding dependency edges from head symbol to each component symbol for each production rule; adding restriction edges between two symbols for each preference rule; transforming restriction edges when graph is acyclic; and removing restriction edges if graph is still acyclic after said transformation.
 38. The method of claim 36 wherein the step of building multiple parse trees compromises the steps of: getting productions in the order determined by the schedule graph; and applying each production (H, M, C, F), in the identified order, to generate new instances of the head H, from the instances of the components M, by using the construction function F, if the components M satisfy constraint C.
 39. The method of claim 36, wherein the step of pruning useless parse trees compromises the additional steps of: for each newly generated instance, checking the conflicting condition of all preference rules to find all conflicts with existing instances; and applying the winning criteria for conflict resolution to remove false instances.
 40. The computer readable storage medium of claim 22, wherein said non-prescribed visual grammar is derived from a plurality of autonomously created Web query forms to represent the hidden syntax convention among the plurality of autonomously created Web query forms.
 41. The method of claim 31, wherein said non-prescribed visual grammar is derived from a plurality of autonomously created Web query forms to represent the hidden syntax convention among the plurality of autonomously created Web query forms.
 42. A computer implemented system for extracting semantic information about a plurality of electronic documents autonomously created by different sources and being accessible via a computer network, comprising: a tokenizer for generating a set of tokens indicative of DOM nodes associated with visual information in a displayed document image from one of the plurality of autonomously created electronic documents accessed via the computer network; a grammar mechanism for deriving a non-prescribed visual grammar from the set of tokens to represent a hidden syntax convention of a visual presentation; and a best-effort parser for applying the derived visual grammar to construct multiple parse trees that represent semantic structure of the document and interpret as many of the set of tokens as the derived visual grammar can.
 43. The system of claim 42, wherein said visual properties include, for each token, the coordinates of the token in the displayed document image, the value of the token, the DOM path of the token in the DOM tree, the type of the token, and the name of the token.
 44. The system of claim 42, wherein said non-prescribed visual grammar is derived from a plurality of autonomously created or heterogeneous Web documents to represent the hidden syntax convention of the visual presentation common among the plurality of autonomously created or heterogeneous Web documents.
 45. The system of claim 44 wherein said hidden syntax convention of visual presentation is derived by performing the following steps: observing the visual relationship of tokens on how they form semantic units, and deriving visual patterns to represent the semantic unit; and observing precedence between different conflicting patterns and deriving pattern preference to represent their precedence.
 46. The system of claim 42 wherein said best-effort parser performs a procedure comprising the steps of: building a schedule graph for determining the order of applying production rules; building multiple parse trees simultaneously by grouping tokens using production rules in determined orders; pruning useless parse trees by checking preference rules; and outputting multiple potential useful parse trees that maximally cover the tokens in the document.
 47. The system of claim 46, wherein the step of building a schedule graph comprises: adding dependency edges from head symbol to each component symbol for each production rule; adding restriction edges between two symbols for each preference rule; transforming restriction edges when graph is acyclic; and removing restriction edges if graph is still acyclic after said transformation.
 48. system of claim 47, wherein the step of building multiple parse trees compromises the steps of: getting productions in the order determined by the schedule graph; and applying each production (H, M, C, F), in the identified order, to generate new instances of the head H, from the instances of the components M, by using the construction function F, if the components M satisfy constraint C.
 49. The system of claim 47, wherein the step of pruning useless parse trees compromises the steps of: for each newly generated instance, checking the conflicting condition of all preference rules to find all conflicts with existing instances; and applying the winning criteria for conflict resolution to remove false instances. 